<?php
namespace App\Http\Controllers\Wx;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Booking;
use App\Models\User;
use App\Http\Requests\ApiRequest;

class BookingController extends Controller
{
    public function index(ApiRequest $request)
    {
        $user = User::where('small_openid',$request->user->small_openid)->first();
        if(!$user) {
            $rs['status'] = false;
            $rs['msg'] = '无查看权限';
            return response()->json($rs);
        }
        
    	$query = Booking::query();    		
    	$list = $query->orderBy('created_at','desc')->paginate(10);
    	$rs['data'] = $list;
    	$rs['status'] = true;
    	return response()->json($rs);


    }

    public function show(ApiRequest $request)
    {
    	$id   = $request->id;
    	$data = Booking::find($id);
    	$rs['data'] = $data;
    	$rs['status'] = true;
    	return response()->json($rs);
    }
}
